/** Copyright Notice:

    Copyright (C) 2011 Ivo Wingelaar

    This software is provided 'as-is', without any express or implied
    warranty.  In no event will the authors be held liable for any damages
    arising from the use of this software.

    Permission is granted to anyone to use this software for any purpose,
    including commercial applications, and to alter it and redistribute it
    freely, subject to the following restrictions:

    1.  The origin of this software must not be misrepresented; you must not
        claim that you wrote the original software. If you use this software
        in a product, an acknowledgment in the product documentation would be
        appreciated but is not required.
    2.  Altered source versions must be plainly marked as such, and must not be
        misrepresented as being the original software.
    3.  This notice may not be removed or altered from any source distribution.

    Please note that the Myth Library is based in part on the work of Nikolaus
    Gebhardt (Irrlicht Engine) and I give full credits to him, and the people who
    helped him for making available an excellent piece of code.

**/

//
// MythCryptoStreamCipherArcFour_C.hpp 010: interface of the arcfour stream cipher
//

#ifndef __MYTH_CRYPTO_SYSTEM_STREAM_CIPHER_ARC_FOUR_C_HPP_INCLUDED__
#define __MYTH_CRYPTO_SYSTEM_STREAM_CIPHER_ARC_FOUR_C_HPP_INCLUDED__

#include "MythCrypto.hpp"

namespace Myth
{
namespace Crypto
{

/** class                 **/
/** StreamCipherArcFour_C **/
//! An interface providing functions to allow the encryption of data (ArcFour)
class StreamCipherArcFour_C : public StreamCipher
{
public:
    /** constructor **/
    /// \param   uint8_t* key
    ///             A pointer to an array of data.
    /// \param   uint16_t
    ///         The length in bytes of the key.
    StreamCipherArcFour_C( uint8_t *key,
                           uint16_t bytes);

    /** destructor **/
    virtual ~StreamCipherArcFour_C();

    /** virtual function **/
    /** init             **/
    //! Initializes the algorithm with a key.
    /// \return void
    /// \param   uint8_t *key
    ///         A pointer to a block of data you want to use as a key.
    /// \param   uint16_t bytes
    ///         The length of the key.
    virtual void init( uint8_t *key,
                       uint16_t bytes);

    /** virtual function **/
    /** transform        **/
    //! Transforms a block of data.
    /// \return void
    /// \param   uint8_t *in
    ///         A pointer to block of data you want to encode.
    /// \param   uint8_t *out
    ///         A pointer to the place you want the encoded data to be written.
    /// \param   size_t bytes
    ///         The size of the block of data.
    virtual void transform( uint8_t *in,
                            uint8_t *out,
                            size_t bytes);

    /** virtual function **/
    /** skip             **/
    //! Skips a specified amount of data.
    /// \return void
    /// \param   size_t n
    ///         The amount you want to skip.
    virtual void skip( size_t n);

private:
    //! Internal state.
    uint8_t mState[258];
};

} // namespace Crypto
} // namespace Myth

#endif // __MYTH_CRYPTO_SYSTEM_STREAM_CIPHER_ARC_FOUR_C_HPP_INCLUDED__
